package com.bba.manager.as.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.bba.manager.api.SkuFeign;
import com.bba.manager.as.mapper.RepairPartsMapper;
import com.bba.manager.as.service.IRepairPartsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bba.manager.common.model.as.RepairParts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 汽车维修所需配件表 服务实现类
 * </p>
 *
 * @author SYANDZZY
 * @since 2025-08-12
 */
@Service
public class RepairPartsServiceImpl extends ServiceImpl<RepairPartsMapper, RepairParts> implements IRepairPartsService {
    @Autowired
    private SkuFeign skuFeign;

    @Override
    public List<RepairParts> ListById(Long repairId) {
        LambdaQueryChainWrapper<RepairParts> query=new LambdaQueryChainWrapper<>(baseMapper);
        List<RepairParts> list = query.eq(RepairParts::getRepairNo, repairId).list();
        return list;
    }

    /**
     * 创建维修订单详情
     */
    @Override
    public void saveRepairParts(RepairParts repairParts) {
        this.save(repairParts);
        skuFeign.decount(repairParts.getPartsNo(),repairParts.getNumber());
    }

}
